import {Episode} from './episode.model';
import {ApiProperty} from '@nestjs/swagger';
import {ModelOptions, prop, Ref} from '@typegoose/typegoose';
import {Category} from "@libs/db/models/category.model";

@ModelOptions({
  schemaOptions: {
    timestamps: true,
    versionKey: false,
    toJSON: {
      virtuals: true,
    },
  },
})
export class Course {
  @prop()
  @ApiProperty({description: '课程名'})
  name: string;

  @prop({
    ref: Category,
    limit: 3
  })
  @ApiProperty({description: '课程分类'})
  categories: Ref<Category>[]

  @prop()
  @ApiProperty({description: '课程描述'})
  description: string

  @ApiProperty({description: '封面图'})
  @prop()
  cover: string;

  @prop({
    ref: 'Episode',
    localField: '_id',
    foreignField: 'course',
  })
  episodes: Ref<Episode>[];
}
